package xin.yangshuai.leetcode01;

/**
 * Climb
 *
 * @author shuai
 * @date 2021/11/20
 */
public class Climb {

    public static void main(String[] args) {
        Climb climb = new Climb();

        int i = climb.climbStairs(10);
        System.out.println(i);
        int i1 = climb.climbStairs(20);
        System.out.println(i1);

    }

    public int climbStairs(int n) {
        int a = 1;
        if (n == 1) {
            return 1;
        }
        int b = 2;

        int i;

        for (i = 3; i <= n; ) {
            a = a + b;
            b = a + b;
            i = i + 2;
        }

        if (n % 2 == 1) {
            return a;
        } else {
            return b;
        }


    }
}


